package ly.sjun.design.factory_pattern;

import ly.sjun.design.factory_pattern.food.Apple;
import ly.sjun.design.factory_pattern.food.Cookie;
import ly.sjun.design.factory_pattern.food.Fructose;

/**
 * @ClassName: FoodFactory
 * @Author: ly
 * @Date: 2023/1/4-9:31
 * @Description 食物生产工厂
 **/
public class FoodFactory {

    public Food produce(String food) {
        if (food == null || "".equals(food)) {
            return null;
        }
        switch (food) {
            case "apple":
                return new Apple();
            case "cookie":
                return new Cookie();
            case "fructose":
                return new Fructose();
            default:
                return null;
        }
    }

}
